<?php
/**
 * @title 201. 数字范围按位与
 * @author start2004
 */

// ini_set("memory_limit", "128M");

class Solution {

    /**
     * @param Integer $m
     * @param Integer $n
     * @return Integer
     */
    function rangeBitwiseAnd($m, $n) {

        $result = $m;
        for ($i=$m+1; $i<=$n; $i++){
            $result = $result & $i;
        }

        /**
         * @return
         */
        return $result;
    }
}



/**
 * @url http://127.0.0.1/leetcode/202008/2020.08.11_7.php
 */
$datas = [
    [5,7],
    [0,1],
    [0,2147483647], // 2^31-1
];

include_once dirname(__DIR__) . DIRECTORY_SEPARATOR ."xhprof.php";
$xhprof = new Xhprof();
foreach ($datas as $data){
    var_dump($data);

    $obj = new Solution();
    $result = $obj->rangeBitwiseAnd($data[0], $data[1]);
    var_dump($result);
    echo str_repeat("<br>", 3);
}
$xhprof->end();
